# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
set (
        SRC_FILES
        native-lib.cpp
        golbal_define.h
        audio_track.cpp
        audio_track.h
        audio_ffmpeg.cpp
        audio_ffmpeg.h
        jni_dplayer.cpp
        jni_dplayer.h
        dplayer_ffmpeg.cpp
        dplayer_ffmpeg.h
        packet_queue.cpp
        packet_queue.h
        dplayer_audio.cpp
        dplayer_audio.h
        dplayer_video.cpp
        dplayer_video.h
        dplayer_status.cpp
        dplayer_status.h
        dplayer_media.cpp
        dplayer_media.h
        yuvengine.cpp

)
add_library(
        native-lib
        SHARED
        ${SRC_FILES})

find_library(log-lib
        log)

find_library(android-lib
        android)

find_library(OpenSLES-lib
        OpenSLES)

# 设置ffmpeg库所在路径的目录
set(distribution_DIR ${CMAKE_SOURCE_DIR}/../libs/${ANDROID_ABI})

add_library(avutil
        SHARED
        IMPORTED)
set_target_properties(avutil
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/libavutil.so)

add_library(swresample
        SHARED
        IMPORTED)
set_target_properties(swresample
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/libswresample.so)

add_library(avfilter
        SHARED
        IMPORTED)
set_target_properties(avfilter
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/libavfilter.so)

add_library(avformat
        SHARED
        IMPORTED)
set_target_properties(avformat
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/libavformat.so)

add_library(swscale
        SHARED
        IMPORTED)
set_target_properties(swscale
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/libswscale.so)

add_library(avcodec
        SHARED
        IMPORTED)
set_target_properties(avcodec
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/libavcodec.so)

# 添加ffmpeg头文件路径
include_directories(${CMAKE_SOURCE_DIR}/../libs/include)
include_directories(${CMAKE_SOURCE_DIR})


target_link_libraries(native-lib
        avcodec
        avfilter
        avformat
        avutil
        swresample
        swscale
        OpenSLES
        ${log-lib}
        ${android-lib})
